import request from '../utils/request';
import { getUid } from '../utils/token';

export async function login(params) {
  return request(`/login`, {
    method: 'POST',
    body: params,
  });
}

export async function register(params) {
  return request(`/register`, {
    method: 'POST',
    body: params,
  });
}

export async function queryCurrent() {
  return request(`/profile`);
}

export async function queryTarget({ uid }) {
  return request(`/users/${uid}`);
}

export async function queryFollowing({ uid }) {
  return request(`/fans-list/${uid}`);
}

export async function queryFans({ uid }) {
  return request(`/fellow-list/${uid}`);
}

export async function changeProfile({ params }) {
  return request(`/users/${getUid()}`, {
    method: 'PUT',
    body: params,
  });
}

export async function follow({ params }) {
  return request(`/fans`, {
    method: 'POST',
    body: params,
  });
}

export async function unfollow({ uid }) {
  return request(`/fans/${uid}`, {
    method: 'DELETE',
  });
}
